#include <stdint.h>
#include <stdio.h>
#include <rtthread.h>
int findmax(int8_t* input, int len){
	int max = input[0];
	int max_index = 0;
	for(int i=1;i<len;i++){
		if(max<input[i]){
			max=input[i];
			max_index = i;
		}
	}
	return max_index;
}

void relu(int8_t* input, int len){
	for(int i=0;i<len;i++){
		if(input[i]<0){
			input[i]=0;
		}
	}
}
void mvm(int8_t* input, int in_len,	int8_t* weight, int w_col,int8_t* output,int shift)
{
	int sum = 0;
	int tmp = 0;
	for(int col=0;col<w_col;col++){
		for(int row=0;row<in_len;row++){
			sum = sum + input[row] * weight[row*w_col + col];
		}
		tmp = sum>>shift;
		output[col] = tmp>127? 127:(tmp<-127?-127:tmp);
		sum = 0;
	}
}

void printmat(int8_t* img, int row, int col){
	for(int i=0;i<row;i++){
		for(int j=0;j<col;j++){
			rt_kprintf("%4d ",img[i*col+j]);
		}
        rt_kprintf("\n");
	}
}
